#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

}

void Widget::timerEvent(QTimerEvent *event)
{
    if(event->timerId()==time_id1)
    {
        static int num=ui->lcdNumber->value();
        ui->lcdNumber->display(num++);
    }
    if(event->timerId()==time_id2)
    {
        int cur=ui->lcdNumber->value();
        cur--;
        if(cur<0)
        {
            killTimer(time_id2);
            return;
        }
        ui->lcdNumber->display(cur);
    }
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_start_clicked()
{
    //启动定时器
    time_id1=startTimer(1000);
    qDebug()<<time_id1;
}

void Widget::on_pushButton_end_clicked()
{
    killTimer(time_id1);
}

void Widget::on_pushButton_down_clicked()
{
    time_id2=startTimer(1000);
    qDebug()<<time_id2;
}
